package com.zbkj.admin.boot.servlet.listener;

import com.zbkj.admin.boot.context.MicaContextProperties;
import com.zbkj.admin.boot.context.MicaHttpHeadersGetter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Servlet 监听器自动配置
 *
 * @author L.cm
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class ServletListenerConfiguration {

	@Bean
	public ServletListenerRegistrationBean<?> registerCustomListener(MicaContextProperties properties,
																	 MicaHttpHeadersGetter httpHeadersGetter) {
		return new ServletListenerRegistrationBean<>(new ServletRequestListener(properties, httpHeadersGetter));
	}

}
